﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Economo.UI.Presenters;
using Economo.UI.Views;

namespace Economo.WinClient.Controls
{
    public partial class ManageBanks : ManageEntities , IManageBanksView 
    {
        public ManageBanks()
        {
            InitializeComponent();            
            _presenter = new ManageBanksPresenter(this);
            //gridViewEntities.CellEndEdit += new DataGridViewCellEventHandler(gridViewBanks_CellEndEdit);            
        }
        private void gridViewEntities_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == gridViewEntities.Columns["Picture"].Index)
            {
                Economo.WinClient.Controls.LoadImage loadImage = new Economo.WinClient.Controls.LoadImage();
                loadImage.OpenImageFile();
                gridViewEntities[e.ColumnIndex, e.RowIndex].Value = loadImage.GetFileBinary;
                OnEntityUpdate(e);
            }
        }
        
        #region ManageBanksView
        public string GetBankDescriptionFromGridRow(int rowIndex)
        {
            return gridViewEntities["Description", rowIndex].Value.ToString();
        }

        public byte[] GetBankPictureFromGridRow(int rowIndex)
        {
            return (byte[])gridViewEntities["Picture", rowIndex].Value;
        }

        public event BankDeleteEventHandler BankDelete;
        #endregion



        //private void ManageBanks_Load(object sender, EventArgs e)
        //{
        //    if (System.Diagnostics.Process.GetCurrentProcess().ProcessName != "devenv")
        //        _presenter.FillData();
        //}
    }
}
